package com.archie.xunji.guangchang.entity;

import android.os.Parcel;
import android.os.Parcelable;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created
 * Author:bi[FR]
 * Date:15-11-10
 */
public class GuangchangData implements Parcelable{


    /**
     * username : 安昭宇
     * topicitemid : 12921423452353
     * user_type : 1
     * description : 现在都说吃重庆火锅、四川火锅，但这险些倒闭……
     * args : 607
     * name : 现在都说吃重庆火锅、四川火锅，但是人家正宗的四川火锅可不是咱这么个吃法
     * labels : 美食
     * action : 1
     * placename : 北京新街口
     * imageurl : http://imagecdn.xunjimap.com/image/cms/story/bdd1d94e-3f53-4081-b6bc-bf4e6db9e946.jpg
     * headurl : cms/story/10df91ce-c244-4ec3-9132-eb22d17a2f29.jpg
     * storyid : 20542452352323
     */

    private String username;
    private long topicitemid;
    private int user_type;
    private String description;
    private String args;
    private String name;
    private String labels;
    private int action;
    private String placename;
    private String imageurl;
    private String headurl;
    private long storyid;



    public void parseJSON(JSONObject json) throws JSONException {

       username=json.getString("username");
        topicitemid=json.getLong("topicitemid");
        user_type=json.getInt("user_type");
        description=json.getString("description");
        args=json.getString("args");
        name=json.getString("name");
        labels=json.getString("labels");
        action=json.getInt("action");
        placename=json.getString("placename");
        imageurl=json.getString("imageurl");
        headurl=json.getString("headurl");
        storyid=json.getLong("storyid");
    }

    @Override
    public String toString() {
        return "GuangchangData{" +
                "username='" + username + '\'' +
                ", topicitemid=" + topicitemid +
                ", user_type=" + user_type +
                ", description='" + description + '\'' +
                ", args='" + args + '\'' +
                ", name='" + name + '\'' +
                ", labels='" + labels + '\'' +
                ", action=" + action +
                ", placename='" + placename + '\'' +
                ", imageurl='" + imageurl + '\'' +
                ", headurl='" + headurl + '\'' +
                ", storyid=" + storyid +
                '}';
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setTopicitemid(long topicitemid) {
        this.topicitemid = topicitemid;
    }

    public void setUser_type(int user_type) {
        this.user_type = user_type;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setArgs(String args) {
        this.args = args;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setLabels(String labels) {
        this.labels = labels;
    }

    public void setAction(int action) {
        this.action = action;
    }

    public void setPlacename(String placename) {
        this.placename = placename;
    }

    public void setImageurl(String imageurl) {
        this.imageurl = imageurl;
    }

    public void setHeadurl(String headurl) {
        this.headurl = headurl;
    }

    public void setStoryid(long storyid) {
        this.storyid = storyid;
    }

    public String getUsername() {
        return username;
    }

    public long getTopicitemid() {
        return topicitemid;
    }

    public int getUser_type() {
        return user_type;
    }

    public String getDescription() {
        return description;
    }

    public String getArgs() {
        return args;
    }

    public String getName() {
        return name;
    }

    public String getLabels() {
        return labels;
    }

    public int getAction() {
        return action;
    }

    public String getPlacename() {
        return placename;
    }

    public String getImageurl() {
        return imageurl;
    }

    public String getHeadurl() {
        return headurl;
    }

    public long getStoryid() {
        return storyid;
    }

//----------------------由于用到Parcelable接口所以要提供一个无参的构造函数 因为Parcelable接口中有带参的构造函数
    public GuangchangData() {
    }

    //-----------------------------实现Parcelable接口需要的方法
    protected GuangchangData(Parcel in) {
        username = in.readString();
        topicitemid = in.readLong();
        user_type = in.readInt();
        description = in.readString();
        args = in.readString();
        name = in.readString();
        labels = in.readString();
        action = in.readInt();
        placename = in.readString();
        imageurl = in.readString();
        headurl = in.readString();
        storyid = in.readLong();
    }

    public static final Creator<GuangchangData> CREATOR = new Creator<GuangchangData>() {
        @Override
        public GuangchangData createFromParcel(Parcel in) {
            return new GuangchangData(in);
        }

        @Override
        public GuangchangData[] newArray(int size) {
            return new GuangchangData[size];
        }
    };




    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(username);
        dest.writeLong(topicitemid);
        dest.writeInt(user_type);
        dest.writeString(description);
        dest.writeString(args);
        dest.writeString(name);
        dest.writeString(labels);
        dest.writeInt(action);
        dest.writeString(placename);
        dest.writeString(imageurl);
        dest.writeString(headurl);
        dest.writeLong(storyid);
    }
}
